﻿using CPPEI.Coolzon.Common;
using CPPEI.Coolzon.ServiceProxy.DataServiceRef;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Visifire.Charts;

namespace CPPEI.Coolzon.UI.DataPartLib
{
    /// <summary>
    ///Interaction logic for DataPartStackedColumn.xaml
    /// </summary>
    [XPartIcon("pack://application:,,,/CPPEI.Coolzon.UI.DataPartLib;component/Images/PartIcons/堆叠柱状图.png")]
    [XPart("ChartStackedColumn", "堆叠柱状图")]
    [System.ComponentModel.DisplayName("堆叠柱状图")]
    public partial class DataPartStackedColumn : DataChartAxisBase
    {
        public DataPartStackedColumn()
        {
            LegendEnabled = true;
            InitializeComponent();
        }
        protected override void SetDefaultDataResult()
        {
            Random random = new Random();
            ServiceProxy.DataServiceRef.DataSeries[] series = new ServiceProxy.DataServiceRef.DataSeries[2];
            for (int j = 1; j <= 2; j++)
            {
                series[j - 1] = new ServiceProxy.DataServiceRef.DataSeries();
                ServiceProxy.DataServiceRef.DataItem[] tmpItems = new ServiceProxy.DataServiceRef.DataItem[5];
                for (int i = 1; i <= 5; i++)
                {
                    tmpItems[i - 1] = new ServiceProxy.DataServiceRef.DataItem();
                    tmpItems[i - 1].Id = "data" + i;
                    tmpItems[i - 1].Name = "data" + i;
                    tmpItems[i - 1].Value = (random.NextDouble()*250).ToString("F2");
                }
                series[j - 1].DataItems = tmpItems;
                series[j - 1].Id = "series" + (j - 1);
                series[j - 1].Name = "series" + (j - 1);
            }
            DataResult = new ServiceProxy.DataServiceRef.DataResult();
            DataResult.DataSeries = series;
        }
        protected override RenderAs GetRender(string dataSeriesId)
        {
            return RenderAs.StackedColumn;
        }

        protected override Chart GetChart()
        {
            return _ctlChart;
        }
    }
}
